<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
    <title>用户修改信息页面</title>
</head>
<?php 
include_once("inc.php");
include_once("base.php");
$tb_name= "user";
$rs = db_get_row("select * from $tb_name where id=".$_SESSION["id"]);
if ($_POST){
	include_once ROOT_PATH."/common/post.php";
	if($_POST["password"]){$data["password"] = "'".$_POST["password"]."'";}
	db_mdf($tb_name,$data,$_REQUEST["id"]);
	urlMsg("08操作成功", "user_edit.php");
}
?>
<script>
function check()
{
	if(document.form1.nickname.value==""){
		alert("昵称为必填");
		document.form1.nickname.focus();
		return false;}
	var str1=document.form1.nickname.value; 
 	var reg1 = /^[\u4e00-\u9fa5]{2,8}$/i; 
	 if (!reg1.test(str1)) 
	 {
	  alert("请输入2-8个汉字！"); 
	  document.form1.nickname.focus();
	  return false;
	  }
	var mobile=document.form1.tel.value;
		if(mobile.length==0) 
       { 
          alert('请输入手机号码！'); 
          document.form1.tel.focus(); 
          return false; 
       }     
       if(mobile.length!=11) 
       { 
           alert('请输入有效的手机号码！'); 
           document.form1.tel.focus(); 
           return false; 
       }
       var myreg = /^(((13[0-9]{1})|(14[0-9]{1})|(15[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+\d{8})$/; 
       if(!myreg.test(mobile)) 
       { 
           alert('请输入有效的手机号码！'); 
           document.form1.tel.focus(); 
           return false; 
       }
		var emailreg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/; 
	if(!emailreg.test(email)){
		document.form1.email.focus();
		alert("邮箱不符合规则");
		return false;
	}
}
</script>
<body>
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
		<tr class="">
			<td width="17" rowspan="2" valign="top"></td>
			<td valign="top">
				<table width="100%" height="31" border="0" cellpadding="0" cellspacing="0">
					<tr>
						<td height="31">
							<div class="title">修改帐户</div>
						</td>
					</tr>
				</table>
			</td>
			<td width="16" rowspan="2"></td>
		</tr>
		<tr>
			<td valign="top" bgcolor="#F7F8F9">
				<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
					<tr>
						<td colspan="4" height="10"></td>
					</tr>
					<tr>
						<td width="1%">&nbsp;</td>
						<td width="96%">
							<table width="100%">
								<tr>
									<td colspan="2">
										<form name="form1" method="post" action="?" onSubmit="return check()" enctype="multipart/form-data">
											<input type="hidden" name="id" value="<?php echo $rs["id"];?>" />
											<table width="100%" class="cont">
												<tr>
													<td width="40%" align="right">
														<span class="red">*</span> 用户名：
													</td>
													<td width=""><?php echo $rs["account"];?></td>
												</tr>
												<tr>
													<td width="" align="right"> 姓名：</td>
													<td width="">
														<input class="text" name="nickname" type="text" maxlength="18" value="<?php echo $rs["nickname"];?>">
													</td>
												</tr>
												<tr>
													<td width="" align="right">
														<span class="red">*</span> 性别：
													</td>
													<td width="">
														<select name="sex">
															<option value="男" <?php if($rs["sex"]=="男"){echo "selected";}?>>男</option>
															<option value="女" <?php if($rs["sex"]=="女"){echo "selected";}?>>女</option>
														</select>
													</td>
												</tr>
												<tr>
													<td width="" align="right">
														<span class="red">*</span> 电话：
													</td>
													<td width="">
														<input class="text" name="tel" type="text" maxlength="18" value="<?php echo $rs["tel"];?>">
													</td>
												</tr>
												<tr>
													<td width="" align="right"> email：</td>
													<td width="">
														<input class="text" name="email" type="text" maxlength="18" value="<?php echo $rs["email"];?>">
													</td>
												</tr>
												<tr>
													<td width="" align="right"> 头像上传：</td>
													<td width="">
														<input type="file" name="img" class="text" id="img">
														<?php 
														if(!empty($rs['img'])){
															?>
															<img src="../Public/Upload/<?php echo $rs["img"];?>" height="50" width="50"/>
														<?php }?>
													</td>
												</tr>
												<tr>
													<td align="right"></td>
													<td>
														<input class="btn" type="submit" value="提交" />
													</td>
												</tr>
											</table>
										</form>
									</td>
								</tr>
							</table>
						</td>
						<td width="1%">&nbsp;</td>
					</tr>
					<tr><td height="20"></td></tr>
				</table>
			</td>
		</tr>
	</table>
</body>
</html>